package com.one.blocks.rbac.controller.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.one.blocks.common.valid.constraints.EnumContains;
import com.one.blocks.mvc.domain.Id;
import com.one.blocks.mvc.valid.Custom;
import com.one.blocks.mvc.valid.Update;
import com.one.blocks.mvc.valid.UpdateSelective;
import com.one.blocks.rbac.enums.MenuTypeEnum;
import com.one.blocks.rbac.valid.constraints.HierarchyMenuType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.groups.Default;
import java.io.Serializable;

/**
 * @author <a href="mailto:idler41@163.con">idler41</a> created on 2022-02-14 13:57:56
 */
@ApiModel(value = "系统目录")
@Data
@HierarchyMenuType(groups = {Custom.class})
public class SysMenuVo implements Serializable, Id<Integer> {

    /**
     * 主键ID
     */
    @ApiModelProperty(value = "主键ID")
    @NotNull(groups = {UpdateSelective.class, Update.class})
    @Null(groups = Default.class)
    private Integer id;

    /**
     * 目录名称(router名称)
     */
    @ApiModelProperty(value = "目录名称(router名称)")
    @NotNull(groups = {Default.class, Update.class})
    private String name;

    /**
     * 目录标题
     */
    @ApiModelProperty(value = "目录标题")
    private String title;

    /**
     * 上级目录id
     */
    @ApiModelProperty(value = "上级目录id")
    private Integer parentId;

    /**
     * 目录类型: 0-目录 1-菜单 2-按钮
     */
    @ApiModelProperty(value = "目录类型: 0-目录 1-菜单 2-按钮")
    @NotNull(groups = {Default.class, Update.class})
    @EnumContains(value = MenuTypeEnum.class,groups = {Default.class, Update.class, UpdateSelective.class})
    private Integer type;

    /**
     * 权限标识
     */
    @ApiModelProperty(value = "权限标识")
    private String perms;

    /**
     * 目录状态: 0-禁用 1-正常
     */
    @ApiModelProperty(value = "目录状态: 0-禁用 1-正常")
    @NotNull(groups = {Default.class, Update.class})
    @Range(min = 0, max = 1, groups = {Default.class, Update.class, UpdateSelective.class})
    private Integer state;

    /**
     * 是否外链: 0-否 1-是
     */
    @ApiModelProperty(value = "是否外链: 0-否 1-是")
    @NotNull(groups = {Default.class, Update.class})
    @Range(min = 0, max = 1, groups = {Default.class, Update.class, UpdateSelective.class})
    private Integer linkFlag;

    /**
     * 是否缓存: 0-否 1-是
     */
    @ApiModelProperty(value = "是否缓存: 0-否 1-是")
    @NotNull(groups = {Default.class, Update.class})
    @Range(min = 0, max = 1, groups = {Default.class, Update.class, UpdateSelective.class})
    private Integer cacheFlag;

    /**
     * 是否可见: 0-否 1-是
     */
    @ApiModelProperty(value = "是否可见: 0-否 1-是")
    @NotNull(groups = {Default.class, Update.class})
    @Range(min = 0, max = 1, groups = {Default.class, Update.class, UpdateSelective.class})
    private Integer visible;

    /**
     * 显示层级
     */
    @ApiModelProperty(value = "显示层级", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Integer levelNum;

    /**
     * 显示顺序
     */
    @ApiModelProperty(value = "显示顺序")
    private Integer orderNum;

    /**
     * 路由地址
     */
    @ApiModelProperty(value = "路由地址")
    private String path;

    /**
     * 组件地址
     */
    @ApiModelProperty(value = "组件地址")
    private String component;

    /**
     * 菜单图标
     */
    @ApiModelProperty(value = "菜单图标")
    private String icon;

    /**
     * 创建者id
     */
    @ApiModelProperty(value = "创建者id", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Integer createId;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Long createTime;

    /**
     * 更新者id
     */
    @ApiModelProperty(value = "更新者id", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Integer updateId;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Long updateTime;
}